home *** CD-ROM | disk | FTP | other *** search
- ---------------------------------------------------------------------------
- Shade
- (S)till (h)as (a) (d)umb nam(e)
-
- Version 1.0 12/14/93
-
- Copyright (C) 1993, Theodore C. Yapo
- ---------------------------------------------------------------------------
-
- 0.5) ------Hardware requirements------
-
- Shade requires a '386 or better computer with VGA. A '486 or better is
- recommended. A math coprocessor is required (it might be built into your
- '486).
-
- (It might work with less, but you'd be very dissapointed by the speed)
-
-
- 1.0) ------What is this "shade" anyway?------
-
- Shade is a utility for viewing shaded 3-d models in real time. The program
- allows you to rotate the model automatically or manually, change the scale,
- lightsource parameters, flat/smooth shading mode, and other stuff.
-
- The package comes with several pre-built models suitable for demos, and since
- the input files are all ASCII and completely explained in this document, you
- can easily create your own 3-d models to view.
-
- The controls can be set using a small instruction set, or interactively
- once the program is running. Alternatively, parameters can be piped into
- the program which can be the last stage in some 3-d viewing application.
- (A 3-d surface plotter would be such an example).
-
- 2.0) ------Show me something!-----
-
- Run the demo batch file. This will give you an idea of what the program
- is capable of, and of the speed at which your machine can run it. The
- real fun comes when you run it interactively, so read on...
-
-
- 3.0) -----Running Interactively------
-
- Pick a simple *.shd file to test the interatctive mode. The star.shd
- file which comes with the package is a good starting point.
-
- To run the program interactively, type
-
- shade <filename.shd>
-
- and then type "go" at the ")" prompt.
-
- Whatever file you chose should appear, shaded and rotating at (hopefully)
- some decent rate. If the display is too slow, press the "-" key a few
- times. This will reduce the size of the model, and should make it
- somewhat faster. Now try the following keys:
-
-
- key function
-
- p toggles auto phi rotation
- t toggles auto theta rotation
- -> moves theta manually, or changes rate (auto mode)
- <- '' but reverse
- (up arrow) moves phi manually, or changes rate (auto mode)
- (down arrow) '' but reverse
- - decreases scale (makes smaller)
- + increases scale (makes larger)
- PgUp increase brightness
- PgDn decrease brightness
- Home increase ambient lighting
- End decrease ambient lighting
- f toggle flat / Gouraud (smooth) mode
- s toggle sun synchronous mode
- c toggle backface culling
- esc | q quits
-
-
- note that the functions are not independent, for example setting
- sun-synchronous mode while culling is on and in flat render mode
- will allow you to see only the triangles that were visible from
- a previous viewpoint...hard to explain, but easy to see.
-
- also, the rotation rates can be increased to infinity or
- thereabouts, so you'll find yourself testing the Nyquist theorem
- if you try to go too fast.
-
-
- 4.0) ------Running in batch mode-------
-
- You can run shade in a batch-style mode. This allows you to set the
- parameters from a file, and then view the result. For example, running
- shade like:
-
- shade file.shd < parmfile
-
- will read the commands in the file "parmfile" into shade, and load the
- file "file.shd" containg a 3-d model. Note that if you want to do this,
- the last line of the parameter file should contain the command
- "go".
-
- To see the commands that can be used type "help" at the ")" prompt.
-
- To see the parameters which can be set, type "show" at the ")" prompt.
-
- I have had quite a bit of success using shade as a 3-d previewer when
- creating objects using BASIC. I wite a BASIC program to create a scene
- file, then include the line
-
- SHELL "shade10.exe object.shd"
-
- at the end of the program. Each time the program is run, then, it allows
- me to view the object. I have found this to be a good visualization tool.
-
-
- 5.0) ------File Format------
-
- The file format is a simple ASCII file containing 3-d positions for
- a number of points, and a number of triangles defined over these points.
- The exact format is:
-
- ---------------------
- number of points
- x1 y1 z1
- x2 y2 z2
- ...
- xn yn zn
-
- number of triangles
- p11 p12 p13 shade1
- p21 p22 p23 shade2
- p31 p32 p33 shade3
- ...
- pm1 pm2 pm3 shadem
- ---------------------
-
-
- 5.1) ------Points------
-
- The points themselves can be any floating-point values. They are
- automatically scaled to the appropriate values internally. The center
- of rotation is chosen as the center of mass (C.O.M.) of the points. If you
- don't like where this places the center, you can add a single extra point
- to move the center of mass anywhere you desire. The details of such a
- scheme are left as an exercise to the reader (I always wanted to say
- that), but here's a rough sketch:
-
- <----------a-----------> <--------b---------->
- +------------------------+- - - - - - - - - - -+
- current desired extra
- C.O.M. C.O.M. point
-
- b = number_of_original_points * a
-
- (If this becomes numerically difficult, put in two or more extra points)
-
-
- 5.2) ------Triangles------
-
- The triangles are defined by specifying the verticies in counter-clockwise
- order when viewed from the outside of the surface, and an shade for that
- triangle. As defined, the normal to the surface points outside. Be careful
- of the point order in defining these triangles, because they can only be
- seen from the outside! (unless you turn culling off).
-
- 1------2
- | /
- | ------> Normal
- inside | / outside
- 3
-
- the normal direction shown is obtained by
- specifying the points in any of the following
- orders:
-
- 2 1 3
- 1 3 2
- 3 2 1
-
- (note that these orders obey a "right hand" rule -
- wrap the fingers of your right hand around the triangle
- in any of these orders, and your thumb gives the normal
- direction)
-
-
- 5.2.1) ------Shades------
-
- The shade value for each triangle determines the intrinsic "color" of
- the triangle. The actual values of the pixels that the traingle is drawn
- with are derived from the shade value by applying the illumination model.
- This allows you to define some dark triangles and some light (to make a
- checkerboard, for instance)
-
- Shade values for triangles should be floating point values between 0 and 1.
-
-
- 5.3) ------Triangle Meshes-----
-
- To make a model work with smooth (Gouraud) shading, it must be defined
- as a mesh. This means that the points of the model are shared by more
- than one triangle. If you have a set of traingles each defined
- by three individual 3-d points, you'll have to convert this into a
- mesh for smooth shading to work (it will also be much faster). The
- easiest way to do this is to write a program which "collapses"
- points less than some distance from each other, and then writes
- the result as a *.shd file. I have experimented with such a program, and
- if there is enough demand, I will clean it up and release it.
-
- example mesh of 16 triangles :
-
- 1 ----- 2 ----- 3 ----- 4 ----- 5
- | / | / | / | / |
- | / | / | / | / |
- 6 ----- 7 ----- 8 ----- 9 ----- 10
- | / | / | / | / |
- | / | / | / | / |
- 11----- 12----- 13----- 14----- 15
-
- *.shd file for mesh:
-
- 15
- x1 y1 z1
- .
- .
- .
- x15 y15 z15
-
- 16
- 2 1 6
- 7 2 6
- 3 2 7
- 8 3 7
- .
- .
- .
- 15 10 14
-
-
- 6.0) ------Known Bugs------
-
- The number of points in an object is limited to 1900, and the number of
- triangles is limited to 2900. Scenes much larger than this would probably
- be terribly slow on todays hardware (at least on mine) anyway. This is
- a segment problem, and could be fixed if needed.
-
- There are occasionally some "dropouts" in certain frames. This is
- probably the fault of the low-level triangle drawing and interpolating code.
- Even though it's written in C, I haven't found the time to chase all the
- bugs down. At most, a few pixels are not written when they should be. (This
- bug is probably more annoying to me than anyone else.)
-
- 7.0) ------Acknowledgements------
-
- Special thanks to Roddy Collins for keyboard, culling, and other clues.
-
- 8.0) -----Whats Next?------
-
- I'm currently working on the following additions: Hopefully they will
- make it into a future release.
-
- * color triangles (still shaded, of course)
- * a mode for (non-real-time) rendering in a large format into a *.pnm file
- * a flat_triangle flag so that you can have some flat, some smooth
- * and the ever popular much, much more...
-
-
- 9.0) -----Contacting Me-----
-
- If you have questions, comments, etc., you can contact me at the address
- below or via email at:
-
- yapot@rpi.edu
-
- If you intend to use this program for commercial purposes,
- please send a donation ($35 sounds about right) to:
-
- Ted Yapo
- c/o 87 Rivercliff Dr.
- Milford, CT 06460
-
- ----------------------------------------------------------------------------
-